#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t,a[100005][3],p[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    for (int oiu=0;oiu<t;oiu++){
        int n,m,l,v;
        cin >> n >> m >> l >> v;
        for (int i=0;i<n;i++){
            cin >> a[i][0]>> a[i][1]>> a[i][2];
        }
        for (int i=0;i<m;i++){
            cin >> p[i];
        }
        int r=p[m-1],ans=0;
        for (int i=0;i<n;i++){
            if (a[i][2]!=0)if(r>=a[i][0]&&(v<a[i][1]||((double)(r-a[i][0])-((double)(v*v-a[i][1]*a[i][1])/(double)(a[i][2]*2))>0.00000001)))ans++;
            else if(v<a[i][1]&&r>=a[i][0])ans++;
        }
        cout << ans << ' ' << m-1 << endl;
    }
    return 0;
}
